﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.Charts.Native;
using ECare.BUS.Data;
using ECare.BUS;

namespace ECare.Client.controls
{
    public partial class ucInInfo : UserControl
    {
        public ucInInfo()
        {
            InitializeComponent();

            this.isUpdateDate = false;
        }


        public bool isUpdateDate { get; set; }

        public SupplyInfo CurrentSupply { get; set; }

        public void LoadInformation()
        {
            this.lblBatchCode.Text = string.Format(this.lblBatchCode.Text, CurrentSupply.supply_code);
            this.lblSupplyCode.Text = string.Format(this.lblSupplyCode.Text, CurrentSupply.supply_code);
            this.lblResourceCode.Text = string.Format(this.lblResourceCode.Text, ResourcesHelper.GetResourceName(CurrentSupply.resource_id));
            this.lblDate.Text = string.Format(this.lblDate.Text, CurrentSupply.supply_date);
            this.lblNumber.Text = string.Format(this.lblNumber.Text, CurrentSupply.supply_number);
            this.lblKG.Text = string.Format(this.lblKG.Text, CurrentSupply.supply_kg);

            this.lblInvalidDate.Text = string.Format(this.lblInvalidDate.Text, CurrentSupply.supply_invalid_time.ToShortDateString());


            this.dateInvalid.Value = CurrentSupply.supply_invalid_time;if (CurrentSupply.supply_invalid_time < DateTime.Now && isUpdateDate)
            {
                //已经失效， 显示失效日期，质检人员可以调整
                this.lblInvalidDate.ForeColor = Color.Red;

                this.dateInvalid.Value = CurrentSupply.supply_invalid_time;
                this.dateInvalid.Visible = true;
            }
            else
            {
                //有效的时候，不显示
                this.dateInvalid.Visible = false;

            }



            this.lblRemark.Text = string.Format(this.lblRemark.Text, CurrentSupply.supply_remark);

            this.lblOperatorInfo.Text = string.Format(this.lblOperatorInfo.Text, UserInfoHelper.GetUserNameById(CurrentSupply.supply_create_by), CurrentSupply.supply_create_time);
            this.lblUpdateInfo.Text = string.Format(this.lblUpdateInfo.Text, UserInfoHelper.GetUserNameById(CurrentSupply.supply_update_by), CurrentSupply.supply_update_time);
        
        //2014、10、6 添加 sheet 弄

            this.lblSheetNo.Text = string.Format(this.lblSheetNo.Text, CurrentSupply.SheetNo);

            this.lblTotalWeight.Text = string.Format(this.lblTotalWeight.Text,
                CurrentSupply.supply_number*CurrentSupply.supply_kg);

        }


        public DateTime GetInvalidate()
        {
            return this.dateInvalid.Value;
        }

    }
}
